package com.util.concurrent.locks.reentrantLock;

import org.junit.Test;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description
 * @Author away
 * @Version V1.0.0
 * @Since 1.0
 * @Date 2019/6/18
 */
public class ReentrantLockDemo {
    private final static Lock lock = new ReentrantLock();

    /**
     * tryLock不一定获取到锁，当用户没有获取到锁时，然后unlock会抛出异常
     */
    @Test
    public  void test01() {
        try {
            lock.tryLock();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
